﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PMS.Client.Entities;
using PMS.Client.IBLL;
using PMS.Client.IDAL;
using PMS.Client.Utils;

namespace PMS.Client.BLL
{
    public class FeeService : ServiceBase, IFeeService
    {
        IFeeAccess _feeAccess;
        public FeeService(IFeeAccess feeAccess)
        {
            _feeAccess = feeAccess;
        }
        public PageEntity<FeeEntity[]> GetFeePage(string key, int index, int size)
        {
            string json = _feeAccess.GetFeePage(key, index, size);
            return this.GetResult<PageEntity<FeeEntity[]>>(json);
        }

        public FeeModeEntity[] GetFeeModes()
        {
            string json = _feeAccess.GetFeeModes();
            return this.GetResult<FeeModeEntity[]>(json);
        }

        public int UpdateFee(FeeEntity fee)
        {
            string json = JsonUtil.Serializer(fee);
            json = _feeAccess.UpdateFee(json);
            return this.GetResult<int>(json);
        }

        public int DeleteFee(int id)
        {
            string json = _feeAccess.DeleteFee(id);
            return this.GetResult<int>(json);
        }

        public int ChangeState(int id, int state)
        {
            string json = _feeAccess.ChangeState(id, state);
            return this.GetResult<int>(json);
        }
    }
}
